package io.zt.dangyuan;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import io.zt.dangyuan.object.CommotListObject;

import java.util.List;

public class BBSCommetAdapter extends BaseAdapter {
	private  LayoutInflater mInflater;
	private List<CommotListObject.ListEntity> datas;
	private Context context;

	public BBSCommetAdapter(Context context, List<CommotListObject.ListEntity> datas) {
		super();
		this.context=context;
		this.datas=datas;
		this.mInflater = LayoutInflater.from(context);
	}
	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return datas.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return datas.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHolder holder = null;
		if (convertView == null) {
			holder=new ViewHolder();
			convertView = mInflater.inflate(R.layout.bbs_commot_item, null);
			holder.tv_itemName = (TextView) convertView.findViewById(R.id.bbs_item_commot_name);
			holder.tv_itemPostion = (TextView) convertView.findViewById(R.id.bbs_item_commot_position);
			holder.tv_itemTime = (TextView) convertView.findViewById(R.id.bbs_item_commot_time);
			holder.iv_itemContent = (TextView) convertView.findViewById(R.id.bbs_item_commot_context);
			convertView.setTag(holder);
		}else {
			holder = (ViewHolder)convertView.getTag();
		}
		CommotListObject.ListEntity object =  datas.get(position);


		holder.tv_itemName.setText(object.getUserRealName());
		holder.tv_itemPostion.setText(object.getDepartment());
		holder.tv_itemTime.setText(String.valueOf(object.getCdate()));
		holder.iv_itemContent.setText(String.valueOf(object.getText()));

		return convertView;
	}

	class ViewHolder   {
		TextView tv_itemName;
		TextView tv_itemPostion;
		TextView tv_itemTime;
		TextView iv_itemContent;
	}



}